﻿using System;
using System.Collections.Generic;
using System.Text;
using LeePong.Game.Shapes;

namespace LeePong.Game.Entities
{
    public class Ball
    {
        public Rectangle Rect;

        // -180 +180
        public int Angle;

        // px per calculated frame
        public float Speed;

        public Ball()
        {
            this.Rect = new Rectangle();
        }

        public void NormalizeSpeed(float targetSpeed, float ratio)
        {
            var diff = Speed - targetSpeed;
            Speed = Speed - (diff * ratio);
        }

        public void InvertAngle()
        {
            this.Angle = -this.Angle;
        }

        public void ReflectAngle()
        {
            this.Angle = 180 - this.Angle;
        }

        public void NormalizeAngle()
        {
            Angle = Angle % 360;
            if (Angle > 180)
            {
                Angle = Angle - 360;
            }
            if (Angle < -180)
            {
                Angle = Angle + 360;
            }
        }
    }
}
